<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div th:if="${session.userName == null}">
    <a href="/login">login</a>
</div>

<span shiro:guest=""> 游客就能看到的内容 </span>

<span shiro:user=""> 登录成功之后才能访问到的 </span>

<div th:if="${session.userName != null}">
    欢迎回来！<span th:text="${session.username}"></span><br/>
    通过shiro的thymeleaf标签获取用户名:<shiro:principal/> <br/>

    <a href="/logout">退出</a>
    <div>
        <a href="/main">main</a>
    </div>

    <div shiro:hasRole="buyer" style="width: 100px;height: 100px;background-color: yellow">
        有buyer角色
    </div>

    <div shiro:hasRole="buyerXXX" style="width: 100px;height: 100px;background-color: yellow">
        有 buyerXXX 角色
    </div>

    <div shiro:hasPermission="manage">
        <a href="/manage">manage</a>
    </div>

    <div shiro:hasRole="admin">
        <a href="/administrator">administrator</a>
    </div>
</div>
</body>
</html>